﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufImpl.h"

namespace gnuf {
    
    // Scenario just is the environment in which the user works. For example,
    // when enter a edit mode, a new scenario will start up. Later, when leave
    // from the edit mode, this scenario will end up. We're using a stack to
    // manage those scenarios.

    class ValueInputSet;

    struct ScenarioState
    {
        ScenarioState() : MianToolbarHint(L""), WorkSpaceKey(L""), CommitCommand(L""), CancelCommand(L"") {}
        ScenarioState(const std::wstring& hint, const std::wstring& workspace,
            const std::wstring& commitId, const std::wstring& cancelId)
            : MianToolbarHint(hint), WorkSpaceKey(workspace), CommitCommand(commitId)
            , CancelCommand(cancelId) {}

        std::wstring MianToolbarHint;
        std::wstring WorkSpaceKey;
        std::wstring CommitCommand;
        std::wstring CancelCommand;

    };

    namespace impl {
        class GNUF_IMPL_CLASS(Scenario);
    }
    
    class GNUF_BASE_EXPORT Scenario : public gcmp::WeakReferenceable
    {
        GNUF_IMPL_USE(Scenario);
        CANNOT_COPY_OR_ASSIGN(Scenario)
    public:
        typedef std::uint8_t ETypes;
        enum class EType : Scenario::ETypes
        {
            eDefault        = 1 << 0,
            eEditMode       = 1 << 1,
            eEmbeddedMode   = 1 << 2
        };
        Scenario(Scenario::EType type);
        ~Scenario();

        typedef std::uint32_t ID;
        Scenario::ID id() const;
        
        // Set/Get the related the related dynamic panel index.
        static void setRelatedDyanamicPanelIndex(int);
        static int relatedDynamicPanelIndex();

        // Return true, if it is the default. Otherwise, return false.
        bool isDefault() const;

        Scenario::EType type() const;
        
        void clear();
        
        // Set/Get the name to conveniently debug.
        void setName(const std::wstring& val);
        const std::wstring& name() const;
        
        // Set/Get the button tool defition key.
        // The methods are for Button Control Tracker. The others should not invoke them.
        void setButtonToolDefKey(const std::wstring& val);
        const std::wstring& buttonToolDefKey() const;

        // Set the value input.
        void setValueInputSet(const std::wstring & caption, ValueInputSet *);

        void setScenarioContext(const ScenarioState& context);
        const ScenarioState& scenarioContext() const;
        ScenarioState& scenarioContext();
    };
    
}
